#include<iostream>

using namespace std;

int main()
{
	int nuts[21][21], M, N, K, temp;
	cin >> M >> N >> K;
	for (int i = 1; i <= M ; i++)
	{
		for (int j = 1; j <= N; j++)
		{
			cin >> temp;
			nuts[i][j] = temp;
		}
	}
	K = K - 2;
	int max = -1, nowM = 0, nowN = 0, tempM = 0, tempN = 0, count = 0;
	while (true)
	{
		for (int i = 1; i <= M; i++)
		{
			for (int j	 = 1; j <= N; j++)
			{
				if (max < nuts[i][j])
				{
					max = nuts[i][j];
					tempM = i;
					tempN = j;
				}
			}
		}
		if (nowM == 0 && nowN == 0)
		{
			if (K - (tempM - 1) - (tempM - 1) - 1 < 0)
			{
				break;
			}
			else
			{
				K -= (tempM - 1) + 1;
			}
		}
		else
		{
			if (K - (abs(tempM - nowM) + abs(tempN - nowN)) - (tempM - 1) - 1 < 0)
			{
				break;
			}else
			{
				K -= (abs(tempM - nowM) + abs(tempN - nowN)) + 1;
			}
		}

		count += nuts[tempM][tempN];
		nowM = tempM;
		nowN = tempN;
		nuts[tempM][tempN] = 0;
		max = 0;
	}
	cout << count;
	return 0;
}